Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

token-cli: Fix compute units arguments #6576

Conversation

acheroncrypto
Copy link
Contributor

Problem

#6501 added compute units arguments, however they don't work because the implementation expects the arguments to be available globally, but they are not:

.arg(
Arg::with_name(COMPUTE_UNIT_LIMIT_ARG.name)
.long(COMPUTE_UNIT_LIMIT_ARG.long)
.takes_value(true)
.value_name("COMPUTE-UNIT-LIMIT")
.validator(is_parsable::<u32>)
.help(COMPUTE_UNIT_LIMIT_ARG.help)
)
.arg(
Arg::with_name(COMPUTE_UNIT_PRICE_ARG.name)
.long(COMPUTE_UNIT_PRICE_ARG.long)
.takes_value(true)
.value_name("COMPUTE-UNIT-PRICE")
.validator(is_parsable::<u64>)
.help(COMPUTE_UNIT_PRICE_ARG.help)
)

Summary of changes

Make compute units arguments global.

Resolves #6575

@mergify mergify bot added the community Community contribution label Apr 13, 2024
@joncinque
Copy link
Contributor

Thanks for submitting the fix! In the meantime, it's possible to use them before the subcommand, ie:

$ spl-token --with-compute-unit-price 100000 create-token

@joncinque joncinque merged commit b1c44c1 into solana-labs:master Apr 15, 2024
31 checks passed
@acheroncrypto
Copy link
Contributor Author

Thanks for submitting the fix! In the meantime, it's possible to use them before the subcommand, ie:

$ spl-token --with-compute-unit-price 100000 create-token

I did that but even when I specified both of them before the subcommand like you suggested, only the compute unit limit instruction was getting included, and it was the default value from the simulation, not the value I specified. While debugging, I realized both CLI arguments were getting set to None even when specified.

$ spl-token --version
spl-token-cli 3.4.0

$ spl-token --with-compute-unit-price 100000 create-token
Creating token Cb8AG4YCxkhQ2cUBdFuTtbuzFKuz71TzuZzFXzPEn86H under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

Address:  Cb8AG4YCxkhQ2cUBdFuTtbuzFKuz71TzuZzFXzPEn86H
Decimals:  9                                                                                                                                                                                                       
Signature: 5hKduzsm1tGhk9nRRDn2E31pYyMQ3v2gfsNS1v5yfangEkH3A336qxVxogf5WffJFNuz9NV8yxpU6AckGUNbptTV

$ solana confirm -v 5hKduzsm1tGhk9nRRDn2E31pYyMQ3v2gfsNS1v5yfangEkH3A336qxVxogf5WffJFNuz9NV8yxpU6AckGUNbptTV
RPC URL: http://localhost:8899
Default Signer Path: /home/x/.config/solana/id.json
Commitment: confirmed

Transaction executed in slot 46:
  Block Time: 2024-04-15T13:44:54+02:00
  Version: legacy
  Recent Blockhash: 7uiJHfGsNLa9qgProZbCL64rBWuPWqd7FJ8FTSomb1AA
  Signature 0: 5hKduzsm1tGhk9nRRDn2E31pYyMQ3v2gfsNS1v5yfangEkH3A336qxVxogf5WffJFNuz9NV8yxpU6AckGUNbptTV
  Signature 1: 2wrwDoL99nDLqj5atkNiqFBgGDjRACWLZ7EjKwkPADCzZVHZ1QWCGhB2QK2svupAmYPRZ6eiHenbLEV8XecDmdn8
  Account 0: srw- GToov3K9LUpvn11qjzTMKzHMZs6cqeRNAbRTjZkmuSSE (fee payer)
  Account 1: srw- Cb8AG4YCxkhQ2cUBdFuTtbuzFKuz71TzuZzFXzPEn86H
  Account 2: -r-x 11111111111111111111111111111111
  Account 3: -r-x ComputeBudget111111111111111111111111111111
  Account 4: -r-- SysvarRent111111111111111111111111111111111
  Account 5: -r-x TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
  Instruction 0
    Program:   11111111111111111111111111111111 (2)
    Account 0: GToov3K9LUpvn11qjzTMKzHMZs6cqeRNAbRTjZkmuSSE (0)
    Account 1: Cb8AG4YCxkhQ2cUBdFuTtbuzFKuz71TzuZzFXzPEn86H (1)
    CreateAccount { lamports: 1461600, space: 82, owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA }
  Instruction 1
    Program:   TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA (5)
    Account 0: Cb8AG4YCxkhQ2cUBdFuTtbuzFKuz71TzuZzFXzPEn86H (1)
    Account 1: SysvarRent111111111111111111111111111111111 (4)
    Data: [0, 9, 229, 189, 84, 246, 184, 224, 190, 189, 199, 53, 195, 131, 98, 216, 214, 127, 66, 82, 130, 24, 52, 86, 54, 153, 241, 233, 142, 35, 64, 112, 41, 251, 0]
  Instruction 2
    Program:   ComputeBudget111111111111111111111111111111 (3)
    Data: [2, 147, 12, 0, 0]
  Status: Ok
    Fee: ◎0.00001
    Account 0 balance: ◎500000000 -> ◎499999999.99852836
    Account 1 balance: ◎0 -> ◎0.0014616
    Account 2 balance: ◎0.000000001
    Account 3 balance: ◎0.000000001
    Account 4 balance: ◎0.0010092
    Account 5 balance: ◎0.9290208
  Compute Units Consumed: 3219
  Log Messages:
    Program 11111111111111111111111111111111 invoke [1]
    Program 11111111111111111111111111111111 success
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
    Program log: Instruction: InitializeMint
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2919 of 3069 compute units
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program ComputeBudget111111111111111111111111111111 invoke [1]
    Program ComputeBudget111111111111111111111111111111 success

Finalized

@joncinque
Copy link
Contributor

Ah, oops, I totally misunderstood how global works. Double thanks then!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

token-cli: Priority fee support doesn't work
2 participants